<template>
  <div class="showcase">
    <nav class="showcase-nav">
      <router-link 
        v-for="module in modules" 
        :key="module.path"
        :to="`/showcase/${module.path}`"
        class="nav-item"
        :class="{ active: currentPath === `/showcase/${module.path}` }"
      >
        <span class="icon">{{ module.icon }}</span>
        <span class="text">{{ module.name }}</span>
      </router-link>
    </nav>
    <main class="showcase-content">
      <router-view v-slot="{ Component }">
        <transition name="fade" mode="out-in">
          <component :is="Component" />
        </transition>
      </router-view>
    </main>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue'
import { useRoute } from 'vue-router'

const route = useRoute()
const currentPath = computed(() => route.path)

const modules = [
  { 
    name: 'HTML5', 
    path: 'html',
    icon: '🌐',
    description: '展示HTML5最新特性和最佳实践'
  },
  { 
    name: 'CSS3', 
    path: 'css',
    icon: '🎨',
    description: '展示现代CSS技术和动画效果'
  },
  { 
    name: 'JavaScript', 
    path: 'javascript',
    icon: '⚡',
    description: '展示JavaScript高级特性和实用技巧'
  },
  { 
    name: 'TypeScript', 
    path: 'typescript',
    icon: '📘',
    description: '展示TypeScript类型系统和高级特性'
  },
  { 
    name: 'Three.js', 
    path: 'threejs',
    icon: '🎮',
    description: '展示Three.js 3D渲染和动画效果'
  },
  { 
    name: 'Vue 3', 
    path: 'vue3',
    icon: '⚛️',
    description: '展示Vue 3的新特性和最佳实践'
  },
  { 
    name: 'Echarts', 
    path: 'echarts',
    icon: '📊',
    description: '展示Echarts数据可视化图表和交互功能'
  }
]
</script>

<style scoped>
.showcase {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, 
    rgba(10, 10, 10, 0.95) 0%,
    rgba(0, 40, 60, 0.95) 50%,
    rgba(10, 10, 10, 0.95) 100%
  );
  padding-top: 60px; /* 为顶部导航栏留出空间 */
}

.showcase-nav {
  width: 220px;
  height: calc(100vh - 60px); /* 减去顶部导航栏高度 */
  padding: 2rem 1rem;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: fixed;
  left: 0;
  top: 60px; /* 从顶部导航栏下方开始 */
  overflow-y: auto;
  z-index: 100;
}

.showcase-content {
  flex: 1;
  margin-left: 220px;
  min-height: calc(100vh - 60px);
  width: calc(100% - 220px);
  padding: 2rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-radius: 10px;
  color: var(--text-color);
  text-decoration: none;
  transition: all 0.3s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(5px);
}

.nav-item.active {
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  box-shadow: 0 5px 15px rgba(0, 255, 136, 0.2);
}

.icon {
  font-size: 1.5rem;
}

.text {
  font-size: 1rem;
  font-weight: 500;
}

.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

@media (max-width: 768px) {
  .showcase {
    flex-direction: column;
    padding-top: 60px;
  }

  .showcase-nav {
    width: 100%;
    height: auto;
    position: sticky;
    top: 60px;
    padding: 1rem;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.8);
  }

  .showcase-content {
    margin-left: 0;
    width: 100%;
    min-height: calc(100vh - 120px); /* 减去顶部导航栏和showcase导航的高度 */
    padding: 1rem;
  }

  .nav-item {
    flex-direction: column;
    padding: 0.5rem;
    text-align: center;
    gap: 0.5rem;
    min-width: 80px;
  }

  .nav-item:hover {
    transform: translateY(-5px);
  }
}
</style> 